package xerrors

import "gitee.com/liuxuezhan/ar-platform/base-common/pkg/xcode"

// * 所有业务错误码为 10 位 int64 数字
// * [1,3] 为业务组
// * [4] 位 0表示API层 1表示RPC层
// * [5,10]位表示对应业务错误码，由业务组自行分配
var (
	UserTokenInvalid             = xcode.New(100001, "用户Token错误")
	ErrHead                      = 6660
	ErrWithDrawAmountNOTENOUGH   = xcode.New(ErrHead+600001, "amount not enough.")
	ErrWithDrawUserWalletNotSave = xcode.New(ErrHead+600002, "UserWallet not save.")
	ErrWithDrawOrderNot          = xcode.New(ErrHead+600003, "WithDrawOrder not .")
	ErrWithDrawOrderNotSave      = xcode.New(ErrHead+600003, "WithDrawOrder not save.")
	ErrInvalidToken              = xcode.New(6660600004, "Invalid token.")
	ErrSignVerifyFailed          = xcode.New(6660600005, "Signature verification failed.")
	ErrSignGenerateFailed        = xcode.New(6660600006, "Signature generation failed.")
	ErrPwdDigestVerifyFailed     = xcode.New(6660600007, "PwdDigest verification failed.")

	// lcl
	ErrDataConvert    = xcode.New(ErrHead+700001, "Failed converting data")
	ErrDuplicatedKey  = xcode.New(ErrHead+700002, "Duplicated key")
	ErrInsert         = xcode.New(ErrHead+700003, "Error inserting data")
	ErrNoRows         = xcode.New(ErrHead+700004, "Record not found")
	ErrUpdate         = xcode.New(ErrHead+700005, "Failed saving data")
	ErrNoRowsAffected = xcode.New(ErrHead+700006, "No rows affected")
)

func New(err error) error {
	return xcode.NewRpc(ErrHead+799999, err.Error())
}
